<!DOCTYPE html>
<html style="background-color: #F1F4FB">

<head>
	<meta charset="utf-8">
	<title>正中参编标准台账页面</title>
	<!--公用样式-->
	<link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
	<link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/supplier/common/css/style.css"/>
	<!--extended-->
	<link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
	<!--Layui-->
	<link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
	<!--公用样式JS-->
	<script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
	<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
	<script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
</head>
<style>
	.Right {
		overflow-y: auto;
		width: 100%;
		left: 16%;
		top: 144px;
	}
	.layui-table-cell {
		text-align: center;
		font-size:14px;
		padding:0 5px;
		height:auto;
		overflow:visible;
		text-overflow:inherit;
		white-space:normal;
		word-break: break-all;
	}
	.layui-laypage-limits select {
		width: 70px;
	}
</style>

<body>
<!--头部-->

<!--容器-->
<div class="layui-container" style="background-color: #ffffff;width:96%;margin-top:60px;padding:16px;border-radius: 10px">
	<!--筛选行-->
	<div style="background-color: #F1F4FB;border-radius: 5px;padding:14px 4% 14px 10px;">
		<div class="layui-row" style="line-height: 50px;padding-left: 3%;">
			<!--标准名称-->
			<div class="layui-col-md2">
				<span>标准名称:</span>
				<input id="bz_name" class="layui-input layui-input-inline" type="text" placeholder="标准名称" style="width: 50%">
			</div>
			<!--标准状态-->
			<div class="layui-col-md2">
				<span>状态:</span>
				<select id="bzzt_select">
					<option value="000">全部</option>
					<#list bzztList as bzzt>
						<option value="${bzzt.badtCode}">${bzzt.badtName}</option>
					</#list>
				</select>
			</div>
			<!--标准级别-->
			<div class="layui-col-md2">
				<span>标准级别:</span>
				<select id="bzjb_select">
					<option value="000">全部</option>
					<#list bzjbList as bzjb>
						<option value="${bzjb.badtCode}">${bzjb.badtName}</option>
					</#list>
				</select>
			</div>
			<!--标准委员会-->
			<div class="layui-col-md3">
				<span>标准委员会:</span>
				<input id="bzwyh_name" class="layui-input layui-input-inline" type="text" placeholder="标准委员会" style="width: 50%">
			</div>
			<!--正中角色-->
			<div class="layui-col-md3">
				<span>正中角色:</span>
				<select id="zzjs_select">
					<option value="000">全部</option>
					<#list zzjsList as zzjs>
						<option value="${zzjs.badtCode}">${zzjs.badtName}</option>
					</#list>
				</select>
			</div>
			<!--正中主要起草人-->
			<div class="layui-col-md3">
				<span>正中主要起草人:</span>
				<input id="zyqcr_name" class="layui-input layui-input-inline" type="text" placeholder="正中主要起草人" style="width: 50%">
			</div>
			<!--发布日期-->
			<div class="layui-col-md4">
				<span>发布日期:</span>
				<input id="fb_date_start" class="layui-input layui-input-inline" type="text" style="width: 32%;" placeholder="开始日期">
				<span>至</span>
				<input id="fb_date_end" class="layui-input layui-input-inline" type="text"  style="width: 32%;" placeholder="结束日期">
			</div>
			<!--实施日期-->
			<div class="layui-col-md4">
				<span>实施日期:</span>
				<input id="ss_date_start" class="layui-input layui-input-inline" type="text" style="width: 32%;" placeholder="开始日期">
				<span>至</span>
				<input id="ss_date_end" class="layui-input layui-input-inline" type="text"  style="width: 32%;" placeholder="结束日期">
			</div>
			<div class="layui-col-md1" style="text-align: end;width: 20%;float: right;">
				<input class="layui-btn layui-btn-normal" style="border-radius:5px;" type="button" value="筛选"
					   onclick="query()">
				<input class="layui-btn layui-btn-normal ml10" type="button"
					   style="border-radius:5px;background-color: #FF5722;" value="重置"
					   onclick="resetQuery()">
			</div>


		</div>
<#--		<div class="layui-row" style="margin-top:10px">-->
<#--			<!--第一发明人&ndash;&gt;-->
<#--			<div class="layui-col-md3" style="text-align: right">-->
<#--				<span>第一发明人:</span>-->
<#--				<input id="dyfmr" class="layui-input layui-input-inline" type="text" placeholder="第一发明人" style="width: 50%">-->
<#--			</div>-->
<#--			<!-- 阶段 &ndash;&gt;-->
<#--			<div class="layui-col-md3" style="text-align: right">-->
<#--				<span>阶段:</span>-->
<#--				<select id="jd_select">-->
<#--					<option value="000">全部</option>-->
<#--					<#list jdList as jd>-->
<#--						<option value="${jd.badtCode}">${jd.badtName}</option>-->
<#--					</#list>-->
<#--				</select>-->
<#--			</div>-->
<#--			<!--专业授权书授权时间&ndash;&gt;-->
<#--			<div class="layui-col-md5" style="text-align: right">-->
<#--				<span>专业授权书授权时间:</span>-->
<#--				<input id="sq_date_start" class="layui-input layui-input-inline" type="text" style="width: 32%;" placeholder="开始时间">-->
<#--				<span>至</span>-->
<#--				<input id="sq_date_end" class="layui-input layui-input-inline" type="text"  style="width: 32%;" placeholder="结束时间">-->
<#--			</div>-->
<#--			<div class="layui-col-md1" style="text-align: center">-->
<#--				&lt;#&ndash;				<input class="layui-btn layui-btn-danger layui-btn-sm fr ml10" type="button" value="重置" onclick="resetQuery()">&ndash;&gt;-->
<#--				<input class="layui-btn layui-btn-normal" type="button"  value="筛选" onclick="query()">-->
<#--			</div>-->
<#--		</div>-->
		<#--		<div class="layui-row" style="margin-top:8px">-->
		<#--				<div class="layui-col-md3 layui-col-md-offset9">-->
		<#--&lt;#&ndash;				<input class="layui-btn layui-btn-danger layui-btn-sm fr ml10" type="button" value="重置" onclick="resetQuery()">&ndash;&gt;-->
		<#--				<input class="layui-btn layui-btn-normal layui-btn-sm fr" type="button"  value="筛选" onclick="query()">-->
		<#--			</div>-->
		<#--		</div>-->
	</div>
	<div style="height:40px"></div>
	<div class="layui-row">
		<div class="layui-col-md3 layui-col-md-offset9">
			<@shiro.hasPermission name="search:export">
			<input class="layui-btn layui-btn-normal layui-btn-sm fr ml10" type="button" value="导出Excel" onclick="exportTable()">
			</@shiro.hasPermission>
			<@shiro.hasPermission name="search:view">
			<input class="layui-btn layui-btn-danger layui-btn-sm fr" type="button" value="预览Excel" onclick="viewTable()">
			</@shiro.hasPermission>
		</div>
	</div>
	<div class="layui-row">
		<table id="booktable" layui-filter="booktable">

		</table>
	</div>

<#--	<div class="Right fr mt10">-->
<#--		<div class="layui-row" style="background-color: #e0e0e0;padding:20px 1%;margin-top:30px;border-radius: 5px">-->
<#--			<div class="layui-col-md2">-->
<#--				<span>计划类别:</span>-->

<#--			</div>-->
<#--			<div class="layui-col-md2" style="width: 26%">-->
<#--				<span style="display: inline-block;width:27%">获取时间:</span>-->
<#--				<input id="hp_time_begin" type="text"  style="display: inline-block;width:35%" value="2021-05-01">-->
<#--				<span>至</span>-->
<#--				<input id="hp_time_end" type="text"  style="display: inline-block;width:35%"  value="2021-05-02">-->
<#--			</div>-->
<#--		</div>-->
<#--	</div>-->
</div>
<div style="height: 50px"></div>
<#--	<!--右侧内容&ndash;&gt;-->
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/tabs.js"></script>
<script type="text/javascript" src="${re.contextPath}/pageoffice.js" id="po_js_main"></script>
<#--<script type="text/html" id="xmjb">-->
<#--	{{# if(d.flag){ }}-->
<#--	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="update"><i class="layui-icon">&#xe640;</i>编辑</a>-->
<#--	{{# }else{ }}-->
<#--	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="handle"><i class="layui-icon">&#xe640;</i>办理</a>-->
<#--	{{# } }}-->
<#--</script>-->
<script type="text/html" id="fmc">
	<div>
		<p>{{d.obj1[0].data1}}</p>
		<p class="cursor" style="color: dodgerblue" onclick='seeAllMembers(&apos;{{d.spfF1}}&apos;,&apos;{{JSON.stringify(d.obj1)}}&apos;)'>查看全部发明人</p>
	</div>
</script>
<script type="text/html" id="nfje">
	<div>
		<p>{{d.obj2[0].data2}}</p>
	</div>
</script>
<script type="text/html" id="nfjfsj">
	<div>
		<p>{{d.obj2[0].data3}}</p>
	</div>
</script>
<script type="text/html" id="nfndkd">
	<div>
		<p>{{d.obj2[0].data4}}</p>
	</div>
</script>
<script type="text/html" id="nfjbr">
	<div>
		<p>{{d.obj2[0].data5}}</p>
	</div>
</script>
<script type="text/html" id="nfqbnf">
	<div>
		<p class="cursor" style="color: dodgerblue" onclick='seeAllNfs(&apos;{{d.spfF1}}&apos;,&apos;{{JSON.stringify(d.obj2)}}&apos;)'>全部年费</p>
	</div>
</script>
<script type="text/javascript">
	var table,tableIns,laydate,form,layer;
	layui.use(['laydate','table','form','layer'], function () {
		laydate = layui.laydate;
		table = layui.table;
		form = layui.form;
		layer = layui.layer;
		//执行一个laydate实例
		laydate.render({
			elem: '#fb_date_start', //见刊时间开思
			type: 'date'
		});
		laydate.render({
			elem: '#fb_date_end', //见刊时间结束
			type: 'date'
		});
		laydate.render({
			elem: '#ss_date_start', //见刊时间开思
			type: 'date'
		});
		laydate.render({
			elem: '#ss_date_end', //见刊时间结束
			type: 'date'
		});

		initTable();

	});

	function setSecondHead(secondHead,count,a){
		var aa = a * 1;

		secondHead[secondHead.length] = {field: 'obj1['+aa+'].data1',title: '姓名'+(aa*1+1), width: '10%',templet:function(d){
				var aObj = d.obj1[aa-1];
				if(aObj && aObj.data1){
					return '<p>'+aObj.data1+'</p>'
				}else{
					return '<p></p>'
				}

			}}

		secondHead[secondHead.length] = {field: 'obj1['+aa+'].data2',title: '排名', width: '8%',templet:function(d){
				var aObj = d.obj1[aa-1];
				if(aObj && aObj.data2){
					return '<p>'+aObj.data2+'</p>'
				}else{
					return '<p></p>'
				}
			}}

		if(aa < count){
			aa = aa +1;
			setSecondHead(secondHead,count,aa);
		}
	}

	function initTable(){
		var jsonData = getQuaryData();
		var qiCaoRenCount = 0;
		//根据条件获取起草人数量:
		layerAjaxGet('/search/decision/getQiCaoRenCount',getQuaryData(),'',function (res) {
			console.log(res);
			if(res.flag){
				qiCaoRenCount = res.data*1;

				var secondHead = [];
				//二级表头添加副主编

				if(qiCaoRenCount && qiCaoRenCount*1>0){
					setSecondHead(secondHead,qiCaoRenCount,0);
				}

				//方法级渲染
				tableIns = table.render({
					id: 'booktable',
					elem: '#booktable',
					url: '/search/decision/form/book/110001',
					height: "full",
					// toolbar: '#toolbarDemo',
					where: jsonData,
					page: true,
					cols: [[
						{
							title: '序号', width: '6%', rowspan: 2, templet: function (res) {
								return res.LAY_INDEX;
							}
						},
						{field: 'spfF1', title: '标准名称', width: '15%', rowspan: 2},
						{field: 'spfF2', title: '状态', width: '8%', rowspan: 2,templet: function (d) {
								return '<span>'+getBzzt(d.spfF2)+'</span>';
							}},
						{field: 'spfF3', title: '标准级别', width: '8%', rowspan: 2,templet: function (d) {
								return '<span>'+getBzjb(d.spfF3)+'</span>';
							}},
						{field: 'spfF4', title: '标准编号', width: '10%', rowspan: 2},
						{field: 'spfF5', title: '标准委员会', width: '10%', rowspan: 2},
						{field: 'spfF6', title: '正中角色', width: '10%', rowspan: 2,templet: function (d) {
								return '<span>'+getZzjs(d.spfF6)+'</span>';
							}},
						{field: 'spfF7', title: '正中单位排名', width: '8%', rowspan: 2},
						{field: 'spfF8', title: '起草单位总数', width: '8%', rowspan: 2},
						{align: 'center', title: '正中主要起草人', colspan: qiCaoRenCount*2},


						{field: 'spfF9', title: '发布单位', width: '15%', rowspan: 2},
						{field: 'spfF10', title: '发布时间', width: '10%', rowspan: 2},
						{field: 'spfF11', title: '实施时间', width: '10%', rowspan: 2},
						{field: 'spfF12', title: '牵头单位名称', width: '15%', rowspan: 2},
						{field: '', title: '标准', width: '10%', rowspan: 2,templet: function(d){
								var returnStr = '';
								if(d.fileList1 && d.fileList1.length > 0){
									for(var a=0;a<d.fileList1.length;a++){
										returnStr = returnStr + '<p>'+d.fileList1[a].fileName+'</p>';
									}
									return returnStr;
								}else{
									return '';
								}
							}},
						{field: 'spfF13', title: '备注', width: '15%', rowspan: 2}
					],
						secondHead]
					,
					done: function (res, currentCount) {

					}
				});


			}
		})

	}

	function getQuaryData(){
		var jsondata = {};
		if($('#bz_name').val()){
			jsondata['spfF1'] = $('#bz_name').val();
		}
		if($('#bzzt_select').val() && $('#bzzt_select').val() != '000'){
			jsondata['spfF2'] = $('#bzzt_select').val();
		}
		if($('#bzjb_select').val() && $('#bzjb_select').val() != '000'){
			jsondata['spfF3'] = $('#bzjb_select').val();
		}
		if($('#bzwyh_name').val()){
			jsondata['spfF5'] = $('#bzwyh_name').val();
		}
		if($('#zzjs_select').val() && $('#zzjs_select').val() != '000'){
			jsondata['spfF6'] = $('#zzjs_select').val();
		}
		if($('#zyqcr_name').val()){
			jsondata['obj9'] = $('#zyqcr_name').val();
		}
		if($('#fb_date_start').val()){
			jsondata['obj1'] = $('#fb_date_start').val();
		}
		if($('#fb_date_end').val()){
			jsondata['obj2'] = $('#fb_date_end').val();
		}
		if($('#ss_date_start').val()){
			jsondata['obj3'] = $('#ss_date_start').val();
		}
		if($('#ss_date_end').val()){
			jsondata['obj4'] = $('#ss_date_end').val();
		}
		return jsondata;
	}



	function query() {
		initTable();
	}

	function resetQuery(){
		$('#bz_name').val('');
		$('#bzzt_select').val('000');
		$('#bzjb_select').val('000');
		$('#bzwyh_name').val('');
		$('#zzjs_select').val('000');
		$('#zyqcr_name').val('');
		$('#fb_date_start').val('');
		$('#fb_date_end').val('');
		$('#ss_date_start').val('');
		$('#ss_date_end').val('');
		var jsondata = {
			bz_name:"",
			bzzt_select:"",
			bzjb_select:"",
			bzwyh_name:"",
			zzjs_select:"",
			zyqcr_name:"",
			fb_date_start:"",
			fb_date_end:"",
			ss_date_start:"",
			ss_date_end:""

		}
		table.reload('booktable', {where: jsonData});
		// query();
	}

	function getZllx(zllx){
		var zllxListStr = '${zllxListStr}';
		var zllxList = JSON.parse(zllxListStr);
		var returnStr = '';
		if(zllxList && zllxList.length>0){
			for(var a=0;a<zllxList.length;a++){
				if(zllx == zllxList[a].badtCode){
					returnStr = zllxList[a].badtName;
				}
			}
		}
		return returnStr;
	}

	function getJd(jd){
		var jdListStr = '${jdListStr}';
		var jdList = JSON.parse(jdListStr);
		var returnStr = '';
		if(jdList && jdList.length>0){
			for(var a=0;a<jdList.length;a++){
				if(jd == jdList[a].badtCode){
					returnStr = jdList[a].badtName;
				}
			}
		}
		return returnStr;
	}

	function viewTable(){
		var jsondata = getQuaryData();
		layerAjaxGet('/search/decision/form/book/viewTable/110001',jsondata,'',function (res) {
			if(res.flag){
				if(res.data){
					var w = ($(window).width()*0.8);
					var h = ($(window).height()*0.8);
					POBrowser.openWindowModeless('/sys/office/openwordTemp?ft=1&fid=' + res.data, 'width=1200px;height=800px;', '{}')
				}
			}
		})
	}

	function exportTable(){
		var para = '';
		if($('#bz_name').val()){
			para = para+'&spfF1='+$('#bz_name').val();
		}
		if($('#bzzt_select').val() && $('#bzzt_select').val() != '000'){
			para = para+'&spfF2='+ $('#bzzt_select').val();
		}
		if($('#bzjb_select').val() && $('#bzjb_select').val() != '000'){
			para = para+'&spfF3='+ $('#bzjb_select').val();
		}
		if($('#bzwyh_name').val()){
			para = para+'&spfF5='+ $('#bzwyh_name').val();
		}
		if($('#zzjs_select').val() && $('#zzjs_select').val() != '000'){
			para = para+'&spfF6='+ $('#zzjs_select').val();
		}
		if($('#zyqcr_name').val()){
			para = para+'&obj9='+ $('#zyqcr_name').val();
		}
		if($('#fb_date_start').val()){
			para = para+'&obj1='+ $('#fb_date_start').val();
		}
		if($('#fb_date_end').val()){
			para = para+'&obj2='+ $('#fb_date_end').val();
		}
		if($('#ss_date_start').val()){
			para = para+'&obj3='+ $('#ss_date_start').val();
		}
		if($('#ss_date_end').val()){
			para = para+'&obj4='+ $('#ss_date_end').val();
		}
		//获取全部数据:
		var url= '/search/decision/form/export/book/110001?a_='+Math.random()+para;
		console.log(url);
		location.href = url;
	}

	function seeAllMembers(zlmc,fmrListStr){
		var names = [];
		var fmrList = JSON.parse(fmrListStr);
		if(fmrList){
			for(var a=0;a<fmrList.length;a++){
				if(fmrList[a].data1){
					var aStData = {};
					aStData.index = a+1;
					aStData.name = fmrList[a].data1;
					names[names.length] = aStData;
				}
			}
			// for(var b=0;b<20;b++){
			// 	var testData = {};
			// 	testData.index = names.length+1;
			// 	testData.name = '测试';
			// 	names[names.length] = testData;
			// }
			localStorage.setItem("form-project-name",zlmc);
			localStorage.setItem("form-project-members",JSON.stringify(names));
			localStorage.setItem("form-project-field-name",'发明人');
			var w = ($(window).width()*0.8);
			var h = ($(window).height()*0.8);
			layer.open({
				type: 2,
				title: false,
				closeBtn: 1,
				shade: 0.8,
				area: [w+'px',h+'px'],
				content: '/search/decision/showMembers',
				success: function(layero, index){

				},
				end: function () {
					localStorage.removeItem("form-project-name");
					localStorage.removeItem("form-project-members");
					localStorage.removeItem("form-project-field-name");
				}
			})
		}
	}


	function seeAllNfs(zlmc,obj2){
		var cols = [];
		var innerCol = [];

		var field1 = {title: '序号', width: '15%', templet: '#index'};
		innerCol[innerCol.length] = field1;
		var field2 =  {field: 'data2',title: '金额（元）', width: '15%'};
		innerCol[innerCol.length] = field2;
		var field3 =  {field: 'data3',title: '缴费时间', width: '30%'};
		innerCol[innerCol.length] = field3;
		var field4 =  {field: 'data4',title: '年费跨度', width: '20%'};
		innerCol[innerCol.length] = field4;
		var field5 =  {field: 'data5',title: '经办人', width: '20%'};
		innerCol[innerCol.length] = field5;
		cols[cols.length] = innerCol;
		localStorage.setItem('form-smart-table-type','colsAndDatas');
		localStorage.setItem("form-project-name",zlmc);
		localStorage.setItem("colsAndDatas-cols",JSON.stringify(cols));
		localStorage.setItem("colsAndDatas-datas",obj2);
		var w = ($(window).width()*0.8);
		var h = ($(window).height()*0.8);
		layer.open({
			type: 2,
			title: false,
			closeBtn: 1,
			shade: 0.8,
			area: [w+'px',h+'px'],
			content: '/search/decision/showMembers',
			success: function(layero, index){

			},
			end: function () {
				localStorage.removeItem("form-project-name");
				localStorage.removeItem("form-project-members");
				localStorage.removeItem("form-project-field-name");
			}
		})
	}

	function getBzzt(bzzt){
		var bzztListStr = '${bzztListStr}';
		var bzztList = JSON.parse(bzztListStr);
		var returnStr = '';
		if(bzztList && bzztList.length>0){
			for(var a=0;a<bzztList.length;a++){
				if(bzzt == bzztList[a].badtCode){
					returnStr = bzztList[a].badtName;
				}
			}
		}
		return returnStr;
	}
	function getBzjb(bzjb){
		var bzjbListStr = '${bzjbListStr}';
		var bzjbList = JSON.parse(bzjbListStr);
		var returnStr = '';
		if(bzjbList && bzjbList.length>0){
			for(var a=0;a<bzjbList.length;a++){
				if(bzjb == bzjbList[a].badtCode){
					returnStr = bzjbList[a].badtName;
				}
			}
		}
		return returnStr;
	}
	function getZzjs(zzjs){
		var zzjsListStr = '${zzjsListStr}';
		var zzjsList = JSON.parse(zzjsListStr);
		var returnStr = '';
		if(zzjsList && zzjsList.length>0){
			for(var a=0;a<zzjsList.length;a++){
				if(zzjs == zzjsList[a].badtCode){
					returnStr = zzjsList[a].badtName;
				}
			}
		}
		return returnStr;
	}

	$(function () {
		//回车事件
		$(document).keydown(function(e){
			// 兼容FF和IE和Opera
			var theEvent = e || window.event;
			var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
			if (code == 13) {
				query();
			}
			return true;
		});
	})
</script>
</body>

</html>
